package com.itheima.day2.exercise;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Supplier;

public class Exercise4 {

    static List<Integer> supply(int count) {
        List<Integer> result = new ArrayList<>();
        for (int i = 0; i < count; i++) {
            // 生成：随机数，但以后可能改变生成规则
            // () -> ThreadLocalRandom.current().nextInt()
            result.add(ThreadLocalRandom.current().nextInt());
        }
        return result;
    }

    static List<Integer> supply(int count, Supplier<Integer> supplier) {
        List<Integer> result = new ArrayList<>();
        for (int i = 0; i < count; i++) {
            // 生成：随机数，但以后可能改变生成规则
            result.add(supplier.get());
        }
        return result;
    }

    public static void main(String[] args) {
        List<Integer> supply = supply(5, () -> ThreadLocalRandom.current().nextInt());
        System.out.println(supply);
    }

}
